home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / DNSetAutoAnswer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  3.1 KB  |  114 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    DNSetAutoAnswer                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        DNSetAutoAnswer.c                                                            */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1994-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1994-05-20    Jaakko Railo        Original version                                        */
  15. /*                                                                                                */
  16. /************************************************************************************************/
  17.  
  18. /****************************************** DESCRIPTION ******************************************
  19.  
  20. *************************************************************************************************/
  21.  
  22. /******************************************** HEADERS *******************************************/
  23.  
  24. #include "TextUtils.h"
  25.  
  26. #ifndef __TELEPHONES__
  27. #include "Telephones.h"
  28. #endif
  29.  
  30. #include "TestModule.h"
  31.  
  32. /****************************************** DEFINITIONS *****************************************/
  33.  
  34. #define    rDisplaySetAutoAnswerDLOG    10000
  35. #define    kAutoAnswerOnItem            2
  36. #define    kAutoAnswerOffItem            3
  37. #define    kAutoAnswerOn                1
  38. #define    kAutoAnswerOff                0
  39.  
  40. /****************************************** PROTOTYPES ******************************************/
  41.  
  42. short        DisplaySetAutoAnswer (void);
  43. void         DoTest (CHRSPtr paramPtr);
  44.  
  45. /************************************************************************************************/
  46. /************************************************************************************************/
  47.  
  48.  
  49. pascal short TestModule (CHRSPtr paramPtr)
  50. {
  51.     short    returnValue = noErr;
  52.     
  53.     if (paramPtr->version <= kTestModuleVersion) {
  54.         
  55.         DoTest (paramPtr);
  56.         
  57.     }
  58.     else
  59.         returnValue = kWrongVersion;
  60.         
  61.     return (returnValue);
  62. }
  63.  
  64.  
  65. short    DisplaySetAutoAnswer (void)
  66. {
  67.     short        itemHit;
  68.     DialogPtr    theDialog;
  69.     
  70.     if ((theDialog = GetNewDialog (rDisplaySetAutoAnswerDLOG, nil, (WindowPtr)(-1L))) != nil) {
  71.         
  72.         ShowWindow (theDialog);
  73.         
  74.         ModalDialog (nil, &itemHit);
  75.                 
  76.         DisposeDialog (theDialog);
  77.     }
  78.     else
  79.         itemHit = -1;
  80.     
  81.     return (itemHit);
  82. }
  83.  
  84.  
  85. void DoTest (CHRSPtr paramPtr)
  86. {
  87.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  88.     TELDNHandle    dnHand;
  89.     short        itemHit;
  90.     OSErr        errCode;
  91.     Boolean        autoAnswer;
  92.     
  93.     if ((dnHand = GetDNHandle (paramPtr)) != nil) {
  94.         itemHit = DisplaySetAutoAnswer ();
  95.         if ((itemHit == kAutoAnswerOnItem) || (itemHit == kAutoAnswerOffItem)) {
  96.             
  97.             autoAnswer = (itemHit == kAutoAnswerOnItem)?kAutoAnswerOn:kAutoAnswerOff;
  98.             
  99.             if ((errCode = TELDNSetAutoAnswer (dnHand, autoAnswer)) == noErr)
  100.                 Print (paramPtr, "TELDNSetAutoAnswer --> AutoAnswer = %s", 
  101.                         ((autoAnswer==kAutoAnswerOn)?"AutoAnswerOn":"AutoAnswerOff"));
  102.             else
  103.                 Print (paramPtr, "### TELDNSetAutoAnswer failed : %d", errCode);
  104.         }
  105.         else
  106.             if (itemHit == -1)
  107.                 Print (paramPtr, "### Unable to get a DLOG resource");
  108.     }
  109.     else
  110.         Print (paramPtr, "### Unable to retrieve the DN handle");
  111. }
  112.  
  113.  
  114.